home *** CD-ROM | disk | FTP | other *** search
Wrap
#!/bin/sh . /etc/system.cfg . /etc/live.cfg . /etc/chat.pwd PATH=/boot/bin:/bin:/sbin:/usr/bin:/usr/sbin:/etc:/tmp:/rc:/mnt/bootdev/router/pkg/rc:/mnt/bootdev/router/rc:. Q="$QUERY_STRING" E="echo" $E "Content-type: text/html" $E "Expires: Thu, 1 Oct 1990 19:32:44 GMT" $E [ "$REMOTE_USER" = admin ] || exit tbl() { $E "<tr>" for i in "$1" "$2" "$3" "$4"; do $E "<td><font face=courier>$i</td>";done $E "</tr>" } form() { usr.cgi cpage "$3<form method=POST action=adm.cgi?$2 target=main><font face=system color=#00FFFF>$1 <input type=text name=line size=25 style='font-family: Courier'> <input type=submit value=Submit> <input type=reset value=Clear></form>" } message() { C="$1 is not running or is disabled" } outpt() { cpage "<pre>${C}</pre>" } get() { read C;C=`$E $C| sed 's/line=//;s///'` } aban() { get C=`$E $C | sed 's.%2F.\/.;s/%2C/,/'` if [ "$1" = un ]; then cat /etc/banlist.cfg | sed -n /$C/!P >/etc/banlist.new if [ -s /etc/banlist.new ]; then mv /etc/banlist.new /etc/banlist.cfg else cpage "Bad argument"; exit fi else $E "$C" >> //etc/banlist.cfg fi cpage "`/rc/rc_masq restart`<br>Address $C has been $1banned" cp /etc/banlist.cfg /mnt/bootdev/router/etc/ } S() { C="`$E "$C" | sed "s.%$1.$2.g;s.%$3.$4.g;s.%$5.$6.g;s.%$7.$8.g"`" } cpage() { usr.cgi cpage "$*" } ttl() { usr.cgi ttl } end() { usr.cgi end } case "$Q" in dyndns) fork dyndns cpage "Request has been made";; dynforce) fork dyndns -f cpage "Request has been made";; listu) ttl $E "</pre><center><br><table border=1 cellspacing=0 cellpadding=3>" tbl User Password "Time/Action" Shell for i in `cat /etc/passwd | sed s/\ /~/g`; do set -- `$E $i| sed 's/:/\ /g;s/*/@/'` P=xxxxxx; [ "$2" = @ ] && P=disabled tbl $1 $P $5 $7 done $E "</table>" end;; del) get if [ "$C" = root ]; then cpage "Protected user '$C'" exit fi cat /etc/passwd | sed /^$C/d >/etc/NEW mv /etc/NEW /etc/passwd cp /etc/passwd /mnt/bootdev/router/etc sync;sync cpage "User '$C' has been deleted";; wlst) ttl $E "</pre><center><br><table border=1 cellspacing=0 cellpadding=3>" for i in `cat /wwa/cgi/.htpasswd`; do set -- `$E $i| sed 's/:/\ /'` $E "<tr><td>$1</td></tr>" done $E "</table>" end;; tpass) cpage "</center><blockquote><blockquote><form method=POST action=adm.cgi?npass target=main>Add or change modem access password for <font face=system color=#00FFFFF>USER <input type=text name=user size=8 style='font-family: Courier'><br>PASSWORD <input type=password name=pass1 size=20 style='font-family: Courier'><br>PASSWORD <input type=password name=pass2 size=20 style='font-family: Courier'><br>Allowed TIME <input type=text name=time size=9 style='font-family: Courier' value='0000-2400'> <input type=submit value=Submit> <input type=reset value=Clear></form></blockquote></blockquote>";; npass) read A eval `$E "$A" | sed 's/&/;/g;s///'` if [ "$user" -a "$user" != root ]; then if [ "$pass1" = "$pass2" ]; then if [ "`cat /etc/passwd | sed -n /^$user:/P`" ]; then cat >/tmp/tmp <<-! $pass1 $pass2 ! cpage "</center><blockquote><blockquote><pre>`cat /tmp/tmp | passwd $user 2>/dev/null`</blockquote></blockquote></pre>" else cat >/tmp/tmp <<-! $user $time $pass1 $pass2 ! cpage "</center><blockquote><blockquote><pre>`cat /tmp/tmp | adduser 2>/dev/null`</blockquote></blockquote></pre>" fi rm /tmp/tmp sync;sync exit else A="Passwords don't match" fi else A="Please enter correct user name" fi cpage "$A" ;; fpass) cpage "</center><blockquote><blockquote><form method=POST action=adm.cgi?cpass target=main>Add or change web access password for <font face=system color=#00FFFFF>USER <input type=text name=user size=8 style='font-family: Courier'><br>PASSWORD <input type=password name=pass1 size=20 style='font-family: Courier'><br>PASSWORD <input type=password name=pass2 size=20 style='font-family: Courier'> <input type=submit value=Submit> <input type=reset value=Clear></form></blockquote></blockquote>";; cpass) read A eval `$E "$A" | sed 's/&/;/g;s///'` if [ "$user" ]; then if [ "$pass1" = "$pass2" ]; then A=`$E "$pass1" | htpasswd /wwa/cgi/.htpasswd "$user"` else A="You misspelled it. Password not changed." fi else A="Please enter correct user name" fi cpage "$A" sync;sync;; wdel) get if [ "$C" = admin ]; then cpage "Protected user '$C'" exit fi cat /wwa/cgi/.htpasswd | sed /^$C:/d >/wwa/cgi/NEW mv /wwa/cgi/NEW /wwa/cgi/.htpasswd sync;sync cpage "User '$C' has been deleted";; dns*) C=`$E $Q| sed s/dns//` C=`/rc/rc_dns $C 2>&1` [ "$C" ] || message DNS outpt;; dhcp*) C=`$E $Q| sed s/dhcp//` C=`/rc/rc_dhcpd $C 2>&1` [ "$C" ] || message DHCP outpt;; httpkill) C=`/rc/rc_httpd stop 2>&1` outpt;; httpstop) N="<a target=main href=adm.cgi?httpkill>Stop HTTP servers</a>" cpage "</center><blockquote>Clicking the link below will completely dissable the web server and control panel. This is the only warning.<br>$N" ;; lpd*) C=`$E $Q| sed s/lpd//` C=`/rc/rc_lpd $C 2>&1` [ "$C" ] || message LPD outpt;; pureftp*) C=`$E $Q| sed s/pureftp//` C=`/rc/rc_ftpd $C` # 2>&1` [ "$C" ] || message FTP outpt;; cron*) C=`$E $Q| sed s/cron//` C=`/rc/rc_crond $C 2>&1` [ "$C" ] || message Cron outpt;; ident*) C=`$E $Q| sed s/ident//` C=`/rc/rc_ident $C 2>&1` [ "$C" ] || message Ident outpt;; tlnet*) C=`$E $Q| sed s/tlnet//` C=`/rc/rc_tlnet $C 2>&1` [ "$C" ] || message Telnet outpt;; mdm*) C=`$E $Q| sed s/mdm//` C=`/rc/rc_ras $C 2>&1` [ "$C" ] || message Dialin outpt;; ring*) set -- `$E $RINGS | sed s/,/\ /` if [ `$E $Q | grep std` ]; then rm -f /etc/morerings R="Number of rings before answer has been<br>reset to standard value RINGS=$RINGS" else : > /etc/morerings R="Number of rings before answer has been changed to $2" fi cpage "Dial-in service.<br><br>$R<br>Changes will take effect within 10 minutes." ;; fwall) C=`/rc/rc_masq restart 2>&1` cpage "<pre>${C}</pre>";; sync) if [ "$TIMADDR" ]; then synctime cpage `cat /tmp/synctime.log` else cpage "No server has been defined" fi ;; ban) aban;; uban) aban un;; blst) cpage "</center></blockquote><blockquote><pre>-- cat /etc/banlist.cfg --<BR>`cat /etc/banlist.cfg | sed -e 's/\#.*//' -e '/^$/d'`</pre>";; fadd) cpage "</center><blockquote><blockquote>Add forwarding of incoming packets <font face=system color=#00FFFFF><p><form method=POST action=adm.cgi?padd target=main>TYPE <input type=text name=type size=3 style='font-family: Courier'> [ tcp, udp ]<BR> PORT or lower range of PORTS<input type=text name=inp size=5 style='font-family: Courier'><BR>to ADDR <input type=text name=outa size=25 style='font-family: Courier'><BR>to PORT or upper Range of -PORTS<input type=text name=outp size=6 style='font-family: Courier'><BR> <input type=submit value=Submit> <input type=reset value=Clear></form>NOTE: To Forward a port range rather than a single port use a - in front of the (to) PORT like. From port 2300 to port -2400</blockquote></blockquote>";; fdel) cpage "</center><blockquote><blockquote>Delete forwarding of incoming packets<font face=system color=#00FFFFF><p><form method=POST action=adm.cgi?pdel target=main>To ADDR <input type=text name=iaddr size=25 style='font-family: Courier'> <input type=submit value=Submit> <input type=reset value=Clear></form></blockquote></blockquote>";; plist) cpage "</center><blockquote><pre>-- cat /etc/portfw.cfg --<BR>`cat /etc/portfw.cfg | sed -e 's/\#.*//' -e '/^$/d'`</pre></blockquote>";; padd) read A eval `$E "$A" | sed 's/&/;/g;s///'` $E "$type,$inp,$outp,$outa" >> /etc/portfw.cfg cp /etc/portfw.cfg /mnt/bootdev/router/etc/ cpage "<pre>`/rc/rc_pfwd restart`</pre>" ;; pdel) read A eval `$E "$A" | sed 's/&/;/g;s///'` cat /etc/portfw.cfg | sed -n /$iaddr/!P >/etc/portfw.new if [ -s /etc/portfw.new ]; then mv /etc/portfw.new /etc/portfw.cfg else cpage "Bad argument"; exit fi cp /etc/portfw.cfg /mnt/bootdev/router/etc/ cpage "<pre>`rc_pfwd restart`</pre>" ;; poff) ipportfw -C; ipautofw -F cpage "Port forwarding table has been cleared.";; prst) cpage "<pre>`rc_pfwd restart`</pre>";; form*) C=`$E $Q| sed s/form//` case "$C" in del) form "Delete console user" $C;; wdel) form "Delete web user" $C;; ban) form "Ban IP ADDR" "$C" "</center><blockquote><blockquote>Format: l,1.2.3.4/32<br>where l or e stands for local or external<br>1.2.3.4 - IP addr of banned host or network<br>/32 - netbits or netmask if banning network<br>Example: l,10.10.10.3<br>Example: e,123.123.123.123/24<br><br>";; uban) form "Unban IP ADDR" $C;; esac;; ethernet|isp.*) ttl $E "</pre><p align=right>FREESCO v$VERSION [$ROUTER] `date`<br><br><br><center>" $E "Router will switch to '$Q' mode in a few seconds<br><br>" end $E "<br><pre>" export LOGNAME=admin@$REMOTE_ADDR MODE=`$E $Q | sed s/isp.//` if [ "$MODE" = ethernet ]; then mode $MODE & else mode dialup $MODE & fi ;; reboot) cpage "Rebooting router" reboot;; shell) ttl; get if [ ! "$C" ]; then end; exit; fi C="`$E "$C" | sed s/+/\ /g`" S 3A ":" 3B ";" 3C "<" 3D "=" S 3E ">" 3F "?" 21 "!" 23 "#" S 24 "$" 25 "%" 26 "\&" 27 "'" S 28 "(" 29 ")" 2B "+" 2C "," S 2F "/" 5B "[" 5D "]" 5E "^" S 7B "{" 7C "|" 7D "}" 7E "~" C=`$E "$C"| sed 's.%5C.\\.g;s.%22.".g;s.%60.`.g'` logger -p auth.info -t "" "[admin@$REMOTE_ADDR] issued: $C" $E eval $C | sed "s/</\<\;/g;s/>/\>\;/g" $E end;; esac